<HTML><HEAD><TITLE>expand_clause(+Term, -TransTerm)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Predicate Database and Compiler</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>expand_clause(+Term, -TransTerm)</H1>
Apply clause transformation to Term
<DL>
<DT><EM>Term</EM></DT>
<DD>A clause term.
</DD>
<DT><EM>TransTerm</EM></DT>
<DD>A variable or term.
</DD>
</DL>
<H2>Description</H2>
    Applies a clause-transformation (clause macro) to Term, if any is
    visible in the caller module (see macro/3). If no transformation
    is visible, TransTerm is identical to Term.
    <P>
    Normally, clause expansion is performed implicitly by the compiler.
    For certain meta-programming applications (e.g. for writing other
    compilers) it can be performed explicitly using expand_clause/2.
    Clause expansion is the second transformation which is applied during
    the compilation process: macro expansion, then clause expansion, then
    goal inlining expansion.
    <P>
    Note that the result of clause transformation can be either a single
    clause or a list of clauses. Transformed clauses should all be standard
    clauses, i.e. either facts or rules with toplevel functor :-/2.

<H3>Modes and Determinism</H3><UL>
<LI>expand_clause(+, -) is det
</UL>
<H3>Modules</H3>
This predicate is sensitive to its module context (tool predicate, see @/2).
<H2>Examples</H2>
<PRE>
    % A grammar rule is an example of a predefined clause transformation:
    ?- expand_clause((p --&gt; q, [tok]), C).

    C = p(_263, _258) :- q(_263, _278), 'C'(_278, tok, _258)
    yes.
</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/syntax/macro-3.html">macro / 3</A>, <A HREF="../../kernel/compiler/expand_goal-2.html">expand_goal / 2</A>, <A HREF="../../lib/source_processor/index.html">library(source_processor)</A>
</BODY></HTML>
